/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ronin.common.model;

import com.ronin.model.constant.DurumEnum;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Version;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

/**
 *
 * @author esimsek
 */
@Entity
@Table(name = "kullanici")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Kullanici.findAll", query = "SELECT k FROM Kullanici k"),
    @NamedQuery(name = "Kullanici.findById", query = "SELECT k FROM Kullanici k WHERE k.id = :id"),
    @NamedQuery(name = "Kullanici.findByAd", query = "SELECT k FROM Kullanici k WHERE k.ad = :ad"),
    @NamedQuery(name = "Kullanici.findBySoyad", query = "SELECT k FROM Kullanici k WHERE k.soyad = :soyad"),
    @NamedQuery(name = "Kullanici.findByTckimlik", query = "SELECT k FROM Kullanici k WHERE k.tckimlik = :tckimlik"),
    @NamedQuery(name = "Kullanici.findByUsername", query = "SELECT k FROM Kullanici k WHERE k.username = :username"),
    @NamedQuery(name = "Kullanici.findByPassword", query = "SELECT k FROM Kullanici k WHERE k.password = :password"),
    @NamedQuery(name = "Kullanici.findByEmail", query = "SELECT k FROM Kullanici k WHERE k.email = :email"),
    @NamedQuery(name = "Kullanici.findByGsm", query = "SELECT k FROM Kullanici k WHERE k.gsm = :gsm")})
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Kullanici implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Long id;
    @Basic(optional = false)
    @Column(name = "ad")
    private String ad;
    @Basic(optional = false)
    @Column(name = "soyad")
    private String soyad;
    @Column(name = "tckimlik")
    private Integer tckimlik;
    @Basic(optional = false)
    @Column(name = "username")
    private String username;
    @Basic(optional = false)
    @Column(name = "password")
    private String password;
    @Column(name = "email")
    private String email;
    @Column(name = "gsm")
    private Integer gsm;
    @OneToMany(cascade = CascadeType.REFRESH, mappedBy = "kullanici",fetch = FetchType.EAGER)
    @Fetch(FetchMode.SELECT)
    @Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
    private List<KullaniciRol> kullaniciRolList;
    
    @Version
    private Long versiyon;
    
    @Enumerated(EnumType.ORDINAL)
    @Column(name = "durum_id")
    private DurumEnum durum;


    
    public Kullanici() {
    }

    public Kullanici(Long id) {
        this.id = id;
    }

    public Kullanici(Long id, String ad, String soyad, String username, String password) {
        this.id = id;
        this.ad = ad;
        this.soyad = soyad;
        this.username = username;
        this.password = password;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getAd() {
        return ad;
    }

    public void setAd(String ad) {
        this.ad = ad;
    }

    public String getSoyad() {
        return soyad;
    }

    public void setSoyad(String soyad) {
        this.soyad = soyad;
    }

    public Integer getTckimlik() {
        return tckimlik;
    }

    public void setTckimlik(Integer tckimlik) {
        this.tckimlik = tckimlik;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Integer getGsm() {
        return gsm;
    }

    public void setGsm(Integer gsm) {
        this.gsm = gsm;
    }

    @XmlTransient
    public List<KullaniciRol> getKullaniciRolList() {
        return kullaniciRolList;
    }

    public void setKullaniciRolList(List<KullaniciRol> kullaniciRolList) {
        this.kullaniciRolList = kullaniciRolList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Kullanici)) {
            return false;
        }
        Kullanici other = (Kullanici) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    public Long getVersiyon() {
        return versiyon;
    }

    public void setVersiyon(Long versiyon) {
        this.versiyon = versiyon;
    }

    public DurumEnum getDurum() {
        return durum;
    }

    public void setDurum(DurumEnum durum) {
        this.durum = durum;
    }
    
    @Override
    public String toString() {
        return "com.ronin.model.Kullanici[ id=" + id + " ]";
    }
    
}
